﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：吕海乐 
    //
    // 文件名：CurrentUserInfo.cs
    // 文件功能描述：当前用户信息查看
    // 创建标识：吕海乐2009-05-15
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
// 审核时间：
// 审核说明：
 //----------------------------------------------------------------*/
using System;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;
using HZ.DrugTrade.Model;

namespace HZ.DrugTrade.Web.CommonPage
{
    public partial class CurrentUserInfo : BasePage
    {
        public CurrentUserInfo()
        {
            this.ModuleNo = "";
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                HZ.DrugTrade.Model.User currentUser =  CurrentAccount.GetUser();
                lblUserID.Text = currentUser.UserID;
                lblUserName.Text = currentUser.UserName;
                lblUserOrg.Text = currentUser.Org.OrgName;
                lblUserRole.Text = currentUser.UserRole.RoleName;

                //仅显示中心端的附加信息
                if (currentUser.UserRole.RoleID == "03")
                {
                    this.pnlCenterOrg.Visible = true;
                    this.lbAreaName.Text = GetFullAreaName(currentUser.Org.Area.AreaID);
                }
                else
                {
                    this.pnlCenterOrg.Visible = false;
                }
            }
        }

        /// <summary>
        /// 获取地区全路径
        /// </summary>
        /// <param name="areaId"></param>
        /// <returns></returns>
        private string GetFullAreaName( string areaId)
        {
            string fullAreaName = "";
            IBLL_Area areaCtrl = Factory.BLL_Area();

            Area area  =  areaCtrl.GetArea(areaId);
            fullAreaName = area.AreaName;
            if (area.FatherAreaID != "0")
            {
                Area father = areaCtrl.GetArea(area.FatherAreaID);
                fullAreaName = father.AreaName + ">>" + fullAreaName;


                if (father.FatherAreaID != "0")
                {
                    Area father2 = areaCtrl.GetArea(area.FatherAreaID);
                    fullAreaName = father2.AreaName + ">>" + fullAreaName;
                }
            }
            return fullAreaName;
        }
    }
}
